// void, Obj This, Obj other

Unit this;
ItemHolder holder;

this = This.AsUnit();
holder = other.AsItemHolder();
 
Sleep(rand(100)+30);
if (.IsValid) {// leave parry mode at new command
	.SetParryMode(false);
	
	if(.hero.IsValid){
		if(.hero.HasItem("irage_battle")){
			Sleep(rand(200)+50);
			.AddCommand(true, "engage");
			return;
		} else if(.hero.HasItem("irage_battle_stand")){
			Sleep(rand(200)+50);
			.AddCommand(true, "stand_position");
			return;
		}
	}
	
	if(.item_count > 0){
		Item item;
		
		item = .FindItem("Terrain bonus I");
		if(item.IsValid)
			.RemoveItemsOfType("Terrain bonus I");
		else {
			item = .FindItem("Terrain bonus II");
			if(item.IsValid)
				.RemoveItemsOfType("Terrain bonus II");
			else {
				item = .FindItem("Terrain bonus III");
				if(item.IsValid)
					.RemoveItemsOfType("Terrain bonus III");
				else {
					item = .FindItem("Terrain bonus IV");
					if(item.IsValid)
						.RemoveItemsOfType("Terrain bonus IV");
				}
			}
		}
	}
}

if(.IsValid)
	if(.IsMilitary)
		if(.speed_factor < 100)                                  
			.SetSpeedFactor(100);
			
if(holder.IsAlive()){
	while(!.Goto(holder,GetConst("GiveDistance"),2000,true,5000));
	
	if(!holder.IsAlive())
		return;
		
	if(!.IsVisible)
		.SetVisible(true);
		
	if (.HasSpecial(sneak)) .SetLastAttackTime(); // mountaineer patch
	
	.OpenItemHolder(holder);
}
